import 'package:flutter/material.dart';
import 'package:flashapp/hello.dart';
import 'package:flashapp/widget.dart';
import 'package:flashapp/layout.dart';
import 'package:flashapp/list.dart';
import 'package:flashapp/grid.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new MaterialApp(
      // 应用名称
      title: 'Flutter Demo',
      theme: new ThemeData(
        // 蓝色主题
        primarySwatch: Colors.blue
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }
  
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text('you have pushed the button this many times:'),
            new Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
            FlatButton(
              child: Text('hello page'),
              textColor: Colors.cyan,
              onPressed: (){
                Navigator.push(context,
                  new MaterialPageRoute(builder: (context){
                    return new Hello();
                  }));
              },
            ),
            FlatButton(
              child: Text('widget page'),
              textColor: Colors.yellow,
              onPressed: () {
                Navigator.push(context,
                    new MaterialPageRoute(builder: (context){
                      return new Echo(text: '传入的文本');
                    })
                );
              },
            ),
            FlatButton(
              child: Text('layout page'),
              textColor: Colors.red,
              onPressed: () {
                Navigator.push(context,
                    new MaterialPageRoute(builder: (context){
                      return new Layout();
                    })
                );
              },
            ),
            FlatButton(
              child: Text('list page'),
              textColor: Colors.blueAccent,
              onPressed: () {
                Navigator.push(context,
                    new MaterialPageRoute(builder: (context){
                      return new List();
                    })
                );
              },
            ),
            FlatButton(
              child: Text('Grid page'),
              textColor: Colors.black,
              onPressed: () {
                Navigator.push(context,
                    new MaterialPageRoute(builder: (context){
                      return new Grid();
                    })
                );
              },
            )
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
        child: new Icon(Icons.access_alarm),
      ),
    );
  }
}

